# 导包
from urllib import request
import re

# msg = input('请输入要翻译的内容：')
# url地址
base_url = 'https://www.mzitu.com/172481'
# 数据格式化
# data = {'msg': msg }

# kw = parse.urlencode(data)

response = request.urlopen(base_url)
# 处理响应信息
html = response.read().decode('utf-8')

# with open('./妹子.html', 'w', encoding='utf-8') as f:
#     f.write(html)
pat = re.compile(r'<img .*? src="(.*?)".*?>')
res = pat.findall(html)
print(res)

# 下载图片
for item in res:
    fname = item.split('/')[-1]

    request.urlretrieve(item,fname)
